use dotenv::dotenv;
use sea_orm::sea_query::{Expr, SimpleExpr};
use std::env;

pub fn upload_host() -> String{
    dotenv().ok();
    let evn_http = env::var("HTTP").unwrap_or_default( );
    let evn_host = env::var("UPLOAD_HOST").unwrap_or_default( );
    let evn_port = env::var("PORT").unwrap_or_default( );

    let http = if evn_http.is_empty() { config::HTTP } else { &evn_http };
    let host = if evn_host.is_empty() { config::UPLOAD_HOST } else { &evn_host };
    let port = if evn_port.is_empty() { config::PORT } else { &evn_port };

    if host.contains(".com") {
        http.to_owned() + "://" + &host + "/"
    }else{
        http.to_owned() + "://" + &host + ":" + port + "/"
    }
}
pub fn upload_url() -> String {  upload_host() + "upload/" }
pub fn download_temp_url() -> String {  upload_host() + "upload/download/temp/" }
pub fn upload_url_expr() -> SimpleExpr { Expr::value(upload_url()) }